import{service} from '@/utils/request'

export function getAllUniversity() {
    return service({
      url: `/api/orgs/univ/`,
      method: 'get'
    })
}

export function getUniversity(pageNum, pageSize) {
    return service({
      url: `/api/orgs/univ/${pageNum}/${pageSize}`,
      method: 'get'
    })
}

export function getUniversityById(id) {
  return service({
    url: `/api/orgs/univ/${id}`,
    method: 'get'
  })
}

export async function addUniversity(data) {
    return await service({
      url: `/api/orgs/univ/addOneUniv`,
      method: 'post',
      data
    })
}

export function updateUniversity(id,data) {
    return service({
      url: `/api/orgs/univ/{upUnivById}?univId=${id}`,
      method: 'put',
      data
    })
}

export function searchUniversityByName(queryInfo) {
  return service({
    url: `/api/orgs/univ/searchUnivByUnivName/${queryInfo.pageNum}/${queryInfo.pageSize}?schoolname=${queryInfo.query}`,
    method: 'get',
  })
}

export function searchUniversityByCity(queryInfo, cityId) {
  return service({
    url: `/api/orgs/univ/searchUnivByCity/${queryInfo.pageNum}/${queryInfo.pageSize}?cityId=${cityId}`,
    method: 'get',
  })
}

export function deleteUniversity(id,data) {
  return service({
    url: `/api/orgs/univ/${id}`,
    method: 'delete',
    data
  })
}

// 导出Excel表格
export function exportExcel() {
  return service({
    url: `/api/orgs/univ/excel/export`,
    method: 'get',
    responseType: 'blob',
    header: {
      headers: { 'Content-Type': 'application/x-download' }
    },
  })
}
